from core import db
from dataclasses import dataclass
from sqlalchemy import UniqueConstraint

@dataclass
class Product(db.Model):
    id:int
    title:str
    image:str

    id = db.Column(db.Integer, primary_key=True, autoincrement=False)
    title = db.Column(db.String(200))
    image = db.Column(db.String(200))

    def __str__(self):
        return self.title

    def __repr__(self):
        return self.title


class UserLike(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer)
    product_id = db.Column(db.Integer)

    UniqueConstraint('user_id', 'product_id', name='user_product_unique')

    def __str__(self):
        return self.id

    def __repr__(self):
        return self.id
